# Makefile for fish pro

IDIR = include
FLAGS = -g -I$(IDIR)
LM = -lm
SRVFLAGS = -lsqlite3
OBJSERVER = server.o svstub.o sockcomCDT.o sockets.o dbHandler.o cypher.o des.o bit.o hton.o ntoh.o tickets.o strlib.o genlib.o random.o exception.o mddriver.o md5c.o aux.o conf.o
OBJCLIENT = client.o clstub.o sockcomCDT.o sockets.o cypher.o des.o bit.o cl.o scanadt.o strlib.o genlib.o exception.o hton.o ntoh.o random.o mddriver.o md5c.o aux.o

DBFILE = proto.db

# Rules for the main objective
all: server client
	@ echo Compiling...
	@ mkdir -p obj
	@ echo Moving all objects to obj directory...
	@ mv *.o obj
	@ echo Execute "make clean" to remove all objecs	

server: $(OBJSERVER)
	@ echo Compiling dependencies for the server...
	@ $(CC) $(OBJSERVER) $(SRVFLAGS) $(LM) -o server

client:  $(OBJCLIENT)
	@ echo Compiling dependencies for the client...
	@ $(CC) $(OBJCLIENT) $(LM) -o client
	
# Rules for secondary objectives
server.o: server.c
	@ $(CC) -c $(FLAGS) $(SRVFLAGS) $?
	
 client.o: client.c
	@ $(CC) -c $(FLAGS) $?
	
clstub.o: clstub.c
	@ $(CC) -c $(FLAGS) $?
	
sockcomCDT.o: sockcomCDT.c
	@ $(CC) -c $(FLAGS) $?

sockets.o: sockets.c
	@ $(CC) -c $(FLAGS) $?

dbHandler.o: ./dbHandler/dbHandler.c
	@ $(CC) -c $(FLAGS) $?

cypher.o: ./cypher/cypher.c
	@ $(CC) -c $(FLAGS) $?

des.o: ./cypher/des.c
	@ $(CC) -c $(FLAGS) $?

bit.o: ./cypher/bit.c
	@ $(CC) -c $(FLAGS) $?
	
cl.o: ../src/parser/cl.c
	@ $(CC) -c $(FLAGS) $?

scanadt.o: ../src/parser/scanADT/scanadt.c
	@ $(CC) -c $(FLAGS) $?

strlib.o: ../src/parser/scanADT/strlib.c
	@ $(CC) -c $(FLAGS) $?
	
genlib.o: ../src/parser/scanADT/genlib.c
	@ $(CC) -c $(FLAGS) $?

exception.o: ../src/parser/scanADT/exception.c
	@ $(CC) -c $(FLAGS) $?
	
hton.o: hton.c
	@ $(CC) -c $(FLAGS) $?

ntoh.o: ntoh.c
	@ $(CC) -c $(FLAGS) $?
	
tickets.o: tickets.c
	@ $(CC) -c $(FLAGS) $?

random.o: ../src/parser/scanADT/random.c
	@ $(CC) -c $(FLAGS) $?
		
mddriver.o: ../src/md5/mddriver.c
	@ $(CC) -c $(FLAGS) $?
	
md5c.o: ../src/md5/md5c.c
	@ $(CC) -c $(FLAGS) $?
	
aux.o: aux.c
	@ $(CC) -c $(FLAGS) $?
	
conf.o: conf.c
	@ $(CC) -c $(FLAGS) $?
	
# Generate the binaries, and put everything where it belongs
clean: all
	@ echo Deleting objects...
	@ rm obj/*.o
	
	